package github.kawaiior.yuanchuxiuzhen.common.item.test;

import github.kawaiior.yuanchuxiuzhen.common.capability.entity.ManaPower;
import github.kawaiior.yuanchuxiuzhen.core.init.itemgroup.YcxzGroup;
import github.kawaiior.yuanchuxiuzhen.core.registry.ModCapability;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;

public class GongFaFast extends Item {
    public GongFaFast() {
        super(new Properties().group(YcxzGroup.YCXZ_GROUP));
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand handIn) {
        LazyOptional<ManaPower> capability = player.getCapability(ModCapability.MANA_POWER);
        capability.ifPresent((power)->{
            if (power.getLearningGongFa() != -1){
                power.addGongFaExp(player, worldIn, 500);
            }
        });
        return super.onItemRightClick(worldIn, player, handIn);
    }
}
